home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / softwareupdate / system / amigados / filefunctions / example1.c < prev    next >
C/C++ Source or Header  |  1996-10-10  |  3KB  |  93 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE)           Amiga C Club (ACC) */
  4. /* --------------------------           ------------------ */
  5. /*                                                         */
  6. /* Manual:  AmigaDOS                    Amiga C Club       */
  7. /* Chapter: File Functions              Tulevagen 22       */
  8. /* File:    Example1.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    93-03-15                                       */
  11. /* Version: 1.0                                            */
  12. /*                                                         */
  13. /*   Copyright 1993, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20. /* This example demonstrates how to create a directory called */
  21. /* "MyDirectory" on the RAM disk.                             */
  22.  
  23.  
  24.  
  25. /* Include the dos library definitions: */
  26. #include <dos/dos.h>
  27.  
  28. /* Now we include the necessary function prototype files:         */
  29. #include <clib/dos_protos.h>       /* General dos functions...    */
  30. #include <stdio.h>                 /* Std functions [printf()...] */
  31. #include <stdlib.h>                /* Std functions [exit()...]   */
  32.  
  33.  
  34.  
  35. /* Set name and version number: */
  36. UBYTE *version = "$VER: AmigaDOS/FileFunctions/Example1 1.0";
  37.  
  38.  
  39.  
  40. /* Declared our own function(s): */
  41.  
  42. /* Our main function: */
  43. int main( int argc, char *argv[] );
  44.  
  45.  
  46.  
  47. /* Main function: */
  48.  
  49. int main( int argc, char *argv[] )
  50. {
  51.   /* A "BCPL" pointer to our lock: */
  52.   BPTR my_dir_lock;
  53.  
  54.  
  55.  
  56.   /* Create a directory: */
  57.   my_dir_lock = CreateDir( "RAM:MyDirectory" );
  58.  
  59.   /* If we got a lock on the directory we have successfully */
  60.   /* created it. However, if we do not have any lock the    */
  61.   /* directory could not be created.                        */
  62.   if( my_dir_lock == NULL )
  63.   {
  64.     /* We could not create the directory! */
  65.     printf( "Error! Could not create the new directory!\n" );
  66.  
  67.     /* Exit with an error code: */
  68.     exit( 20 );
  69.   }
  70.   
  71.   /* We have successfully created the directory! We must */
  72.   /* now be careful to unlock it as soon as we do not    */
  73.   /* need the lock any more.                             */
  74.   printf( "The directory was successfully created!\n" );
  75.  
  76.  
  77.  
  78.   /* As soon as you do not need the lock on the */
  79.   /* directory any more you should unlock it!   */
  80.   UnLock( my_dir_lock );
  81.  
  82.   /* Inform the user: */
  83.   printf( "Directory unlocked!\n" );
  84.  
  85.  
  86.  
  87.   /* The End! */
  88.   exit( 0 );
  89. }
  90.  
  91.  
  92.  
  93.